package com.example.swordjava;


import static com.example.temp.PrintTest.n;

public class Test66 {

    public static void main(String[] args) {

        int[][] a = {{1, 2, 3, 4},
                {5, 6, 7, 8},
                {9, 10, 11, 12},
                {13, 14, 15, 16}};

        System.out.println(Math.pow(1, 10));

    }

    public class TreeNode {
        int val = 0;
        Test45.TreeNode left = null;
        Test45.TreeNode right = null;

        public TreeNode(int val) {
            this.val = val;

        }
    }

    /**
     * JZ66
     * 给定一个数组 A[0,1,...,n-1] ,请构建一个数组 B[0,1,...,n-1] ,其中 B 的元素 B[i]=A[0]*A[1]*...*A[i-1]*A[i+1]*...*A[n-1]
     * （除 A[i] 以外的全部元素的的乘积）。程序中不能使用除法。（注意：规定 B[0] = A[1] * A[2] * ... * A[n-1]，B[n-1] = A[0] * A[1] * ... * A[n-2]）
     * 对于 A 长度为 1 的情况，B 无意义，故而无法构建，用例中不包括这种情况。
     */

    public int[] multiply(int[] A) {
        // write code here
        int length = A.length;
        int[] res = new int[length];
        res[0] = 1;
        for (int i = 1; i < length; i++) {
            res[i] = res[i - 1] * A[i - 1];
        }

        int rightPart = 1;
        for (int i = length - 2; i >= 0; i--) {
            rightPart = rightPart * A[i + 1];
            res[i] = res[i] * rightPart;
        }
        return res;
    }

}














